import { reqGetBannerList,reqCategoryList,reqFloorList } from "@/api"

// Home模块小仓库
const state = {
  // 轮播图数据
  bannerList: [],
  // 三级联动
  categoryList: [],
  // floor数据
  floorList:[]
}

const mutations = {
  GETBANNERLIST(state, bannerList) {
    state.bannerList = bannerList
  },
  CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList
  },
  GETFLOORLIST(state,floorList){
    state.floorList = floorList
  }
}

const actions = {
  // 获取首页轮播图的数据
  async getBannerList(context) {
    let result = await reqGetBannerList()
    if (result.code === 200) {
      context.commit("GETBANNERLIST", result.data)
    }
  },
  // 获取三级联动数据
  async categoryList(context) {
    let result = await reqCategoryList()
    if (result.code === 200) {
      context.commit("CATEGORYLIST", result.data)
    }
  },
  // 获取floor数据
  async getFloorList(context){
    let result = await reqFloorList()
    if(result.code == 200){
      context.commit("GETFLOORLIST",result.data)
    }
  }
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
}
